<template>
  <div class="cmt-container">
    <h3>评论列表：</h3>
    <hr>
    <textarea placeholder="请输入评论内容（最多120字）" maxlength="120"></textarea>
    <mt-button type="primary" size="large">发表评论</mt-button>
    <div class="cmt-list">
      <div class="cmt-item" v-for="item in comments" :key="item.id">
        <div class="cmt-title">
          第{{item.id+1}}楼　用户：{{item.name}}　发表时间：{{item.time}}
        </div>
        <div class="cmt-body">
          {{item.title}}
        </div>
      </div>
    </div>

    <mt-button type="danger" size="large" plain>加载更多</mt-button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      comments: []
    }
  },
  created() {
    this.getComments()
  },
  methods: {
    getComments(){
      this.$http.get('vuecomment').then(result => {
        if(result.body){
          // 成功了
          this.comments = result.body
        } else {
          console.log('评论列表获取失败')
        }
      })
    }
  },
}
</script>

<style lang="scss" scoped>
.cmt-container{
  h3{
    font: 18px/25px "微软雅黑";
  }
  textarea{
    font-size: 13px;
    height: 85px;
    margin: 0;
  }
  .cmt-list{
    margin: 5px 0;
    font: 12px/30px "微软雅黑";
    .cmt-title{
      background-color: #ccc;
      display: flex;
      justify-content: space-between;
    }
    .cmt-body{
      text-indent: 2em;
      font-size: 13px;
    }
  }

}
</style>
